#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using webapp4U.DAL;
#endregion


namespace webapp4U.BOL
{
	 public class Category
	 {
         #region Member Variables

         private Int32 _cateID;

         private String _appKey;

         private String _cateName;

         private String _cateName_en;

         private String _cateDesc;

         private String _imageUrl;

         private Int32 _cateOrder;

         private Int32 _parentCateID;

         #endregion


         #region Public Properties

         public Int32 CateID
         {
             get { return _cateID; }
             set { _cateID = value; }
         }

         public String AppKey
         {
             get { return _appKey; }
             set { _appKey = value; }
         }

         public String CateName
         {
             get { return _cateName; }
             set { _cateName = value; }
         }

         public String CateName_en
         {
             get { return _cateName_en; }
             set { _cateName_en = value; }
         }

         public String CateDesc
         {
             get { return _cateDesc; }
             set { _cateDesc = value; }
         }

         public String ImageUrl
         {
             get { return _imageUrl; }
             set { _imageUrl = value; }
         }

         public Int32 CateOrder
         {
             get { return _cateOrder; }
             set { _cateOrder = value; }
         }

         public Int32 ParentCateID
         {
             get { return _parentCateID; }
             set { _parentCateID = value; }
         }

         #endregion


	     #region public static Methods
         

         //Get top Category HomePage
         public static List<Category> GetTopCategoryHomePageByParentID(int CateID)
         {
             CategoryDAL db = new CategoryDAL();
             return db.GetTopCategoryHomePageByParentID(CateID);
         }

         // lay nhung loai cong viec hien thi o trang chu
         public static List<Category> GetCategoryHomePageByParentCateID(Int32 ParentCateID)
         {
             CategoryDAL db = new CategoryDAL();
             return db.GetCategoryHomePageByParentCateID(ParentCateID);
         }


	     public static int Insert(Category obj)
	     {
		     CategoryDAL db = new CategoryDAL();
		     return db.Insert(obj);
	     }

	     public static bool Update(Category obj)
	     {
		     CategoryDAL db = new CategoryDAL();
		     return db.Update(obj);
	     }

	     public static bool Delete(Int32 CateID)
	     {
             // nhung loai khong duoc xoa vi se anh huong den he thong
             if (CateID == Globals.ConvertToInt32(eCategory.DanhMucSanPham))
                 return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.Raovat))
             //    return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.NguoiVietNam))
             //    return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.NguoiNuocNgoai))
             //    return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.NguoiVN_LaoDongChuyenMonCao))
             //    return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.NguoiVN_LaoDongPhoThong))
             //    return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.NguoiNN_LaoDongChuyenMonCao))
             //    return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.NguoiNN_LaoDongPhoThong))
             //    return false;
             
             // khong thuoc nhung loai tren thi xoa
		     CategoryDAL db = new CategoryDAL();
		     return db.Delete(CateID); 
	     }

	     public static Category GetCategoryByID(Int32 CateID)
	     {
		     CategoryDAL db = new CategoryDAL();
		     return db.GetCategoryByID(CateID);
	     }

         public static string GetCateNameByCateID(Int32 CateID)
         {
             Category obj = GetCategoryByID(CateID);
             return (Globals.LangVietNam())? obj.CateName : obj.CateName_en;
         }


	     //Get All Category
	     public static List<Category> GetAllCategory(int PageIndex, int PageSize)
	     {
		     CategoryDAL db = new CategoryDAL();
		     return db.GetAllCategory(PageIndex, PageSize);
	     }

	     // Get Count All records of Table  Category
	     public static int GetCountCategory()
	     {
		     CategoryDAL db = new CategoryDAL();
		     return db.GetCountCategory();
	     }


         public static Int32 GetAutoCateID()
         {
             CategoryDAL db = new CategoryDAL();
             return db.GetAutoCateID();
         }


         public static List<Category> GetCategoryByParentCateID(Int32 ParentCateID)
         {
             CategoryDAL db = new CategoryDAL();
             return db.GetCategoryByParentCateID(ParentCateID);
         }


	 #endregion
	 }
}
